<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>咨询页面</title>
    <script src="js/axios.min.js"></script>
    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/vue.js"></script>
    <script src="layui/layui.js"></script>
    <script src="js/vue-router.js"></script>
    <link rel="stylesheet" href="layui/css/layui.css"/>
    <link rel="stylesheet" href="css/goods.css"/>
    <link rel="stylesheet" href="/static/build/layui.css" media="all">
</head>
<body>

<table class="layui-hide" id="test" lay-filter="test"></table>



<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">回复</a>

</script>


<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#test'
            ,url:'http://47.94.138.204:7790/example/checkallconsult'
            ,where:
                {
                    sid:localStorage.getItem("seller_id")
                }
            ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }]
            ,title: '订单数据表'


            /*

            [
            {"usermame":"11","id":"1212"},
            {"usermame":"11","id":"1212"},
            {"usermame":"11","id":"1212"},
            {"usermame":"11","id":"1212"},
            ]

            * */

            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'consultantid', title:'顾客编号', width:100, fixed: 'left', unresize: true, sort: true}
                ,{field:'serverid', title:'客服编号', width:100, fixed: 'left', unresize: true, sort: true}

                ,{field:'content', title:'咨询内容', width:100, fixed: 'left', unresize: true, sort: true}
                ,{field:'time', title:'咨询时间', width:190, edit: 'text'}
                ,{field:'reply', title:'回复', width:100, edit: 'text'}

                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
            ]]
            ,page: true
        });

        //头工具栏事件


        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'edit'){
                layer.prompt({
                    formType: 2
                    ,value: data.reply
                }, function(value, index){
                    obj.update({
                        reply: value
                    });
                    $.ajax({
                        type:"GET",
                        url:"http://47.94.138.204:7790/example/updateconsult?consultantid=" + obj.data.consultantid +"&serverid=" + obj.data.serverid+"&time="+obj.data.time+"&content="+obj.data.content+"&reply="+value,
                        success:function(data){
                            alert("http://127.0.0.1:7747/admin/userroot?sid=" + obj.data.id +"&root=" + value)
                        },
                    });
                    layer.close(index);
                });

            }
        });
    });
</script>

</body>
</html>